<template>
  <div class="body-container">
    <div class="logo hidden-xs-only show">
      <img :src="whiteLogo" width="100%">
      <span class="title">用户授权中心</span>
    </div>
    <div id="sign-container" class="sign-container" :class="switchPanelShow?'right-panel-active':''">
      <div class="sign-up form-container">
        <form id="sign-up-form">
          <div class="title"><h1>注册</h1><a class="hidden-sm-and-up"><span @click="switchPanel"><i class="zs-icon zs-shouzhi"></i>登录</span></a></div>
          <input type="text" name="mobile" placeholder="手机号码"  v-model="mobile"/>
          <input type="password" name="password" placeholder="密码"  v-model="password" />
          <button type="button" id="sign-up-submit" @click="doSignUp">注册</button>
          <div class="social-container">
            <a href="#" class="social"><i class="zs-icon zs-qq"></i></a>
            <a href="#" class="social"><i class="zs-icon zs-weibo1"></i></a>
            <a href="#" class="social"><i class="zs-icon zs-weixin"></i></a>
          </div>
          <span>第三方账号注册</span>
        </form>
      </div>
      <div class="sign-in form-container">
        <form id="sign-in-form">
          <div class="title"><h1>登录</h1><a class="hidden-sm-and-up"><span @click="switchPanel"><i class="zs-icon zs-shouzhi"></i>注册</span></a></div>
          <input type="text" name="mobile" placeholder="手机号码" v-model="mobile"/>
          <input type="password" name="password" placeholder="密码" v-model="password" />
          <a href="#">忘记密码？</a>
          <button  type="button" id="sign-in-submit" @click="doSignIn">登录</button>
          <div class="social-container">
            <a href="/oauth/qq" class="social"><i class="zs-icon zs-qq"></i></a>
            <a href="/oauth/weibo" class="social"><i class="zs-icon zs-weibo1"></i></a>
            <a href="/oauth/wechat" class="social"><i class="zs-icon zs-weixin"></i></a>
          </div>
          <span>第三方账号登录</span>
        </form>
      </div>
      <div class="overlay-container hidden-xs-only">
        <div class="overlay">
          <div class="overlay-panel overlay-left">
            <h1>欢迎回来！</h1>
            <p>请您先登录的个人信息，进行操作。</p>
            <button class="ghost" @click="switchPanel">登录</button>
          </div>
          <div class="overlay-panel overlay-right">
            <h1>你好朋友！</h1>
            <p>输入您的个人信息注册成为会员。</p>
            <button class="ghost" @click="switchPanel">注册</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
	import metaMixin from '@mixins/metaMixin.js'
    import WhiteLogo from '@assets/images/logo-white.png';
	import {BASE_API_URL} from '@config/index';
	export default {
		name: 'Login',

		mixins: [ metaMixin ],

		components: {
    },

		props: {},

		data() {
			return {
				title: '登录-注册-用户中心',
				switchPanelShow: false,
        localHash:window.location.hash,
				whiteLogo:WhiteLogo,
				mobile:'',
				password:'',
			}
		},

		computed: {},

		watch: {},

		created() {
			if( this.localHash === '#register'  ){
				this.switchPanel();
      }
		},

		mounted() {
		},

		destroyed() {
		},

		methods: {
			switchPanel:function(){
        this.switchPanelShow = !this.switchPanelShow;
        if( this.switchPanelShow ){
	        this.$router.replace('#register');
	        this.localHash = '#register';
        }else{
	        this.$router.replace('');
	        this.localHash = '';
        }
      },
			doSignIn:function(){
				var t = this;
				t.mobile = _.trim(t.mobile);
				t.password = _.trim(t.password);
				if( _.isEmpty(t.mobile) || _.isEmpty(t.password) ){
					return false;
				}
        t.$api.member.normalSignIn({
          mobile: t.mobile,
          password: t.password,
        }).then(res=>{
        	this.$message.success( res.msg );
        	window.location.href=BASE_API_URL+'/';
        }).catch(res=>{
        	console.log(res);
	        this.$message.error( res.msg );
        });
			},
			doSignUp:function(){

			}
    }
	}
</script>

<style scoped lang="scss">

  a{
    color: $subsidiary-color;
    &:hover,&:active,&:focus{
      color: $primary-color;
    }
  }

  .logo{
    width: auto;
    margin: 200px auto 0 auto;
    text-align: center;
    img{
      width: 300px;
      display: inline-block;
    }
    .title{
      display: inline-block;
      font-size: 55px;
      line-height: 90px;
      vertical-align: top;
      color: #333333;
    }
  }

  @media only screen and (max-width: 767px) {
    .sign-container{
      margin: 2.5rem auto!important;
    }
    .title{
      text-align: left;
      width: 100%;
      position: relative;
      vertical-align: bottom;
      .hidden-sm-and-up{
        position: absolute;
        right: 1rem;
        vertical-align: bottom;
        font-size: 18px;
        line-height: 2;
        i{
          font-size: 1.4rem;
        }
      }
    }
    .sign-in{
      .title{
        margin-bottom:20px;
      }
    }
    h1{
      /*font-weight: 400!important;*/
      color: $primary-color;
    }
    form{
      padding: 0 1rem!important;
    }
    .sign-up,.sign-in{
      width:100%!important;
    }
    .social-container  i{
      &.zs-qq{
        color:#0FA2EF
      }
      &.zs-weibo1{
        color:#FF0000
      }
      &.zs-weixin{
        color:#59CA0D
      }
    }
    .right-panel-active {
      .sign-up {
        transform: translateX(0)!important;
        animation: show 0.6s;
      }
    }
  }

  @media only screen and (min-width: 768px) {
    .social-container  i{
      &.zs-qq{
        color:#0FA2EF
      }
      &.zs-weibo1{
        color:#FF0000
      }
      &.zs-weixin{
        color:#59CA0D
      }
    }
  }
  @media only screen and (min-width: 992px) {
    .social-container  i {
      &.zs-qq {
        color: $subsidiary-color
      }

      &.zs-weibo1 {
        color: $subsidiary-color
      }

      &.zs-weixin {
        color: $subsidiary-color
      }
    }
  }

  h1 {
    font-size: 2.5rem;
    margin: 0;
    margin-bottom: .5rem;
    font-weight: 500;
    line-height: 1.2;
    display: inline-block;
  }
  a {
    /*color: #333;*/
    font-size: 14px;
    text-decoration: none;
    margin: 15px 0;
  }

  p {
    font-size: 14px;
    font-weight: 100;
    line-height: 20px;
    letter-spacing: 0.5px;
    margin: 20px 0 30px;
  }
  .sign-container{
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25),
    0 10px 10px rgba(0, 0, 0, 0.22);
    position: relative;
    overflow: hidden;
    min-height: 480px;
    margin: 10rem auto;
  }

  button {
    border-radius: 1rem;
    border: 2px solid #FF4B2B;
    background-color: #FF4B2B;
    color: #FFFFFF;
    font-size: 1rem;
    width: 12rem;
    height: 2.8rem;
    letter-spacing: .5rem;
    transition: all $transition-time ease-in;
    outline: none;
    &:hover{
      opacity: .7;
    }
    &:focus {
      outline: none;
    }
    &.ghost {
      background-color: transparent;
      border-color: #FFFFFF;
    }
  }

  form {
    background-color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 0 3rem;
    height: 100%;
    text-align: center;
  }

  input {
    background-color: #eee;
    border: none;
    padding: 1rem .8rem;
    margin: .8rem 0;
    width: 100%;
    border-radius: .5rem;
  }
  .form-container{
    position: absolute;
    top: 0;
    height: 100%;
    transition: all 0.6s ease-in-out;
  }
  .sign-in {
    left: 0;
    width: 50%;
    transform: translateX(0%);
    animation: show 0.6s;
  }
  .sign-up {
    left: 0;
    width: 50%;
    transform: translateX(100%);
    animation: show 0.6s;
  }


  @keyframes show {
    0%, 49.99% {
      opacity: 0;
      z-index: 1;
    }

    50%, 100% {
      opacity: 1!important;
      z-index: 10!important;
    }
  }


  .overlay-container {
    position: absolute;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    overflow: hidden;
    transition: transform 0.6s ease-in-out;
    z-index: 100;
  }
  .overlay {
    background: #FF416C;
    background: -webkit-linear-gradient(to right, #FF4B2B, #FF416C);
    background: linear-gradient(to right, #FF4B2B, #FF416C);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: 0 0;
    color: #FFFFFF;
    position: relative;
    left: -100%;
    height: 100%;
    width: 200%;
    transform: translateX(0);
    transition: transform 0.6s ease-in-out;
  }
  .overlay-panel {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 0 3rem;
    text-align: center;
    top: 0;
    height: 100%;
    width: 50%;
    transform: translateX(0);
    transition: transform 0.6s ease-in-out;
  }
  .overlay-left {
    transform: translateX(-20%);
  }
  .overlay-right {
    right: 0;
    transform: translateX(0);
  }
  .social-container {
    margin: 1rem 0 .5rem 0;
    padding: 0.5rem;
    border-bottom: 1px solid #333333;
  }
  .social-container  i{
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin: 0 1rem;
    font-size: 2.3rem;
    color: $subsidiary-color;
    &.zs-qq:hover{
      color:#0FA2EF
    }
    &.zs-weibo1:hover{
      color:#FF0000
    }
    &.zs-weixin:hover{
      color:#59CA0D
    }
  }
  .right-panel-active{
    .sign-in {
      transform: translateX(100%);
    }
    .sign-up {
      transform: translateX(100%);
      opacity: 1;
      z-index: 5;
    }
    .overlay-container {
      transform: translateX(-100%);
    }
    .overlay {
      transform: translateX(50%);
    }
    .overlay-left {
      transform: translateX(0);
    }
    .overlay-right {
      transform: translateX(20%);
    }
  }
</style>
